﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using viBook.Common;

namespace viBook.Models
{
    public class User
    {
        private string _avatarUrl;
        public int Id { get; set; }

        [Required(ErrorMessage = "Email is required.")]
        public string Email { get; set; }

        [MaxLength(20, ErrorMessage = "Username cannot be longer than 20 characters.")]
        public string Username { get; set; }

        public string Password { get; set; }


        public DateTime JoinedDate { get; set; }
        public DateTime? LastJoined { get; set; }
        public string Location { get; set; }
        public string Status { get; set; }

        public string AvatarUrl
        {
            get { return string.IsNullOrEmpty(_avatarUrl) ? Constant.DefaultUserAvatar : _avatarUrl; }
            set { _avatarUrl = value; }
        }

        [MaxLength(500, ErrorMessage = "Biography cannot be longer than 500 characters.")]
        public string Biography { get; set; }

        public bool IsExternal { get; set; }
        public bool IsAdmin { get; set; }
        public bool IsBlocked { get; set; }
        public string ValidationCode { get; set; }

        public virtual IEnumerable<Book> UploadedBooks { get; set; }
        public virtual IEnumerable<Activity> Activities { get; set; }

        public string DisplayName { get; set; }

        [NotMapped]
        public int NumberOfUploadedBook { set; get; }

        [NotMapped]
        public bool IsReported { set; get; }
    }
}